package br.fbc.action;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import br.fbc.model.User;

import com.opensymphony.xwork2.ActionSupport;

public class ImageAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	HttpServletRequest request;
	private String erro;

	public String getQrText(String qrfield) {

		if (null == qrfield || "".equals(qrfield)){
			//TODO enum
			qrfield = "http://www.facebook.com/profile.php?id="+((User) getFromSession("user")).getId()+"&sk=info";
		}

		return qrfield;
	}
	
	public void workWithSession(HttpServletRequest request, User user){		
		//String userId = request.getParameter("fb_sig_user");		
		request.getSession().setAttribute("user", user);	
		
	}
	
	public Object getFromSession(String key){
		return getRequest().getSession().getAttribute(key);
	}
	
	public HttpServletRequest getRequest(){
		HttpServletRequest request = ServletActionContext.getRequest();
		return request;
	}

	public String getErro() {
		return erro;
	}

	protected void setErro(String erro) {
		this.erro = erro;
	}


}